package net.wanho.controller;

import com.github.pagehelper.PageInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.RequiredArgsConstructor;
import net.wanho.po.Student;
import net.wanho.service.StudentService;
import net.wanho.vo.AjaxResult;
import org.springframework.web.bind.annotation.*;

/**
 * Author：汤小洋
 * Date：2024-01-08 15:10
 * Description：<描述>
 */
@Api(tags = "03.学生接口")
@RestController
@RequestMapping("/students")
@RequiredArgsConstructor
public class StudentController {

    private final StudentService studentService;

    @ApiOperation("分页查询")
    @GetMapping
    public AjaxResult findPage(@ApiParam("当前页") @RequestParam(defaultValue = "1") int pageNum,
                               @ApiParam("页大小") @RequestParam(defaultValue = "5") int pageSize,
                                 @ApiParam("查询条件") Student stu){
        PageInfo<Student> pageInfo = studentService.findPage(pageNum,pageSize,stu);
        return AjaxResult.success(pageInfo);
    }

    @ApiOperation("根据id查询")
    @GetMapping("/{id}")
    public AjaxResult findById(@PathVariable Integer id){

        return AjaxResult.success();
    }

    @ApiOperation("新增")
    @PostMapping
    public AjaxResult add(@RequestBody Student stu){

        return AjaxResult.success();
    }

    @ApiOperation("修改")
    @PutMapping
    public AjaxResult update(@RequestBody Student stu){

        return AjaxResult.success();
    }

    @ApiOperation("删除")
    @DeleteMapping("/{id}")
    public AjaxResult delete(@PathVariable Integer id){

        return AjaxResult.success();
    }

}
